{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "lesbian-springer",
   "metadata": {},
   "source": [
    "## Seldon V2 Pipeline to Pipeline Examples\n",
    "\n",
    "This notebook illustrates a series of Pipelines that are joined together.\n",
    "\n",
    "### Models Used\n",
    "\n",
    " * `gs://seldon-models/triton/simple` an example Triton tensorflow model that takes 2 inputs INPUT0 and INPUT1 and adds them to produce OUTPUT0 and also subtracts INPUT1 from INPUT0 to produce OUTPUT1. See [here](https://github.com/triton-inference-server/server/tree/main/docs/examples/model_repository/simple) for the original source code and license.\n",
    " * Other models can be found at https://github.com/SeldonIO/triton-python-examples"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "running-antarctica",
   "metadata": {},
   "source": [
    "### Pipeline pulling from one other Pipeline\n",
    "\n",
    "![pipeline-to-pipeline](img_pipeline1.jpg)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "id": "0f2ab2a3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "apiVersion: mlops.seldon.io/v1alpha1\n",
      "kind: Model\n",
      "metadata:\n",
      "  name: tfsimple1\n",
      "spec:\n",
      "  storageUri: \"gs://seldon-models/triton/simple\"\n",
      "  requirements:\n",
      "  - tensorflow\n",
      "  memory: 100Ki\n",
      "apiVersion: mlops.seldon.io/v1alpha1\n",
      "kind: Model\n",
      "metadata:\n",
      "  name: tfsimple2\n",
      "spec:\n",
      "  storageUri: \"gs://seldon-models/triton/simple\"\n",
      "  requirements:\n",
      "  - tensorflow\n",
      "  memory: 100Ki\n"
     ]
    }
   ],
   "source": [
    "!cat ./models/tfsimple1.yaml\n",
    "!cat ./models/tfsimple2.yaml"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "id": "f9e073d7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{}\n",
      "{}\n"
     ]
    }
   ],
   "source": [
    "!seldon model load -f ./models/tfsimple1.yaml \n",
    "!seldon model load -f ./models/tfsimple2.yaml "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "id": "997b4028",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{}\n",
      "{}\n"
     ]
    }
   ],
   "source": [
    "!seldon model status tfsimple1 -w ModelAvailable | jq -M .\n",
    "!seldon model status tfsimple2 -w ModelAvailable | jq -M ."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "id": "3d017ede",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "apiVersion: mlops.seldon.io/v1alpha1\r\n",
      "kind: Pipeline\r\n",
      "metadata:\r\n",
      "  name: tfsimple\r\n",
      "spec:\r\n",
      "  steps:\r\n",
      "    - name: tfsimple1\r\n",
      "  output:\r\n",
      "    steps:\r\n",
      "    - tfsimple1\r\n"
     ]
    }
   ],
   "source": [
    "!cat ./pipelines/tfsimple.yaml"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "id": "following-winning",
   "metadata": {},
   "outputs": [],
   "source": [
    "!seldon pipeline load -f ./pipelines/tfsimple.yaml"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "id": "artistic-kentucky",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\r\n",
      "  \"pipelineName\": \"tfsimple\",\r\n",
      "  \"versions\": [\r\n",
      "    {\r\n",
      "      \"pipeline\": {\r\n",
      "        \"name\": \"tfsimple\",\r\n",
      "        \"uid\": \"cieq5dqi8ufs73flaj4g\",\r\n",
      "        \"version\": 1,\r\n",
      "        \"steps\": [\r\n",
      "          {\r\n",
      "            \"name\": \"tfsimple1\"\r\n",
      "          }\r\n",
      "        ],\r\n",
      "        \"output\": {\r\n",
      "          \"steps\": [\r\n",
      "            \"tfsimple1.outputs\"\r\n",
      "          ]\r\n",
      "        },\r\n",
      "        \"kubernetesMeta\": {}\r\n",
      "      },\r\n",
      "      \"state\": {\r\n",
      "        \"pipelineVersion\": 1,\r\n",
      "        \"status\": \"PipelineReady\",\r\n",
      "        \"reason\": \"created pipeline\",\r\n",
      "        \"lastChangeTimestamp\": \"2023-06-29T15:26:48.074696631Z\",\r\n",
      "        \"modelsReady\": true\r\n",
      "      }\r\n",
      "    }\r\n",
      "  ]\r\n",
      "}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline status tfsimple -w PipelineReady | jq -M ."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "id": "87f10a5c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\r\n",
      "  \"model_name\": \"\",\r\n",
      "  \"outputs\": [\r\n",
      "    {\r\n",
      "      \"data\": [\r\n",
      "        2,\r\n",
      "        4,\r\n",
      "        6,\r\n",
      "        8,\r\n",
      "        10,\r\n",
      "        12,\r\n",
      "        14,\r\n",
      "        16,\r\n",
      "        18,\r\n",
      "        20,\r\n",
      "        22,\r\n",
      "        24,\r\n",
      "        26,\r\n",
      "        28,\r\n",
      "        30,\r\n",
      "        32\r\n",
      "      ],\r\n",
      "      \"name\": \"OUTPUT0\",\r\n",
      "      \"shape\": [\r\n",
      "        1,\r\n",
      "        16\r\n",
      "      ],\r\n",
      "      \"datatype\": \"INT32\"\r\n",
      "    },\r\n",
      "    {\r\n",
      "      \"data\": [\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0\r\n",
      "      ],\r\n",
      "      \"name\": \"OUTPUT1\",\r\n",
      "      \"shape\": [\r\n",
      "        1,\r\n",
      "        16\r\n",
      "      ],\r\n",
      "      \"datatype\": \"INT32\"\r\n",
      "    }\r\n",
      "  ]\r\n",
      "}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline infer tfsimple \\\n",
    "    '{\"inputs\":[{\"name\":\"INPUT0\",\"data\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],\"datatype\":\"INT32\",\"shape\":[1,16]},{\"name\":\"INPUT1\",\"data\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],\"datatype\":\"INT32\",\"shape\":[1,16]}]}' | jq -M ."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "id": "00575d89",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "apiVersion: mlops.seldon.io/v1alpha1\r\n",
      "kind: Pipeline\r\n",
      "metadata:\r\n",
      "  name: tfsimple-extended\r\n",
      "spec:\r\n",
      "  input:\r\n",
      "    externalInputs:\r\n",
      "      - tfsimple.outputs\r\n",
      "    tensorMap:\r\n",
      "      tfsimple.outputs.OUTPUT0: INPUT0\r\n",
      "      tfsimple.outputs.OUTPUT1: INPUT1\r\n",
      "  steps:\r\n",
      "    - name: tfsimple2\r\n",
      "  output:\r\n",
      "    steps:\r\n",
      "    - tfsimple2\r\n"
     ]
    }
   ],
   "source": [
    "!cat ./pipelines/tfsimple-extended.yaml"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "id": "8fcd8947",
   "metadata": {},
   "outputs": [],
   "source": [
    "!seldon pipeline load -f ./pipelines/tfsimple-extended.yaml"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "id": "5a69008c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\r\n",
      "  \"pipelineName\": \"tfsimple-extended\",\r\n",
      "  \"versions\": [\r\n",
      "    {\r\n",
      "      \"pipeline\": {\r\n",
      "        \"name\": \"tfsimple-extended\",\r\n",
      "        \"uid\": \"cieq5h2i8ufs73flaj50\",\r\n",
      "        \"version\": 1,\r\n",
      "        \"steps\": [\r\n",
      "          {\r\n",
      "            \"name\": \"tfsimple2\"\r\n",
      "          }\r\n",
      "        ],\r\n",
      "        \"output\": {\r\n",
      "          \"steps\": [\r\n",
      "            \"tfsimple2.outputs\"\r\n",
      "          ]\r\n",
      "        },\r\n",
      "        \"kubernetesMeta\": {},\r\n",
      "        \"input\": {\r\n",
      "          \"externalInputs\": [\r\n",
      "            \"tfsimple.outputs\"\r\n",
      "          ],\r\n",
      "          \"tensorMap\": {\r\n",
      "            \"tfsimple.outputs.OUTPUT0\": \"INPUT0\",\r\n",
      "            \"tfsimple.outputs.OUTPUT1\": \"INPUT1\"\r\n",
      "          }\r\n",
      "        }\r\n",
      "      },\r\n",
      "      \"state\": {\r\n",
      "        \"pipelineVersion\": 1,\r\n",
      "        \"status\": \"PipelineReady\",\r\n",
      "        \"reason\": \"created pipeline\",\r\n",
      "        \"lastChangeTimestamp\": \"2023-06-29T15:27:01.095715504Z\",\r\n",
      "        \"modelsReady\": true\r\n",
      "      }\r\n",
      "    }\r\n",
      "  ]\r\n",
      "}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline status tfsimple-extended -w PipelineReady | jq -M ."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "id": "e7e19259",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\r\n",
      "\t\"model_name\": \"\",\r\n",
      "\t\"outputs\": [\r\n",
      "\t\t{\r\n",
      "\t\t\t\"data\": [\r\n",
      "\t\t\t\t2,\r\n",
      "\t\t\t\t4,\r\n",
      "\t\t\t\t6,\r\n",
      "\t\t\t\t8,\r\n",
      "\t\t\t\t10,\r\n",
      "\t\t\t\t12,\r\n",
      "\t\t\t\t14,\r\n",
      "\t\t\t\t16,\r\n",
      "\t\t\t\t18,\r\n",
      "\t\t\t\t20,\r\n",
      "\t\t\t\t22,\r\n",
      "\t\t\t\t24,\r\n",
      "\t\t\t\t26,\r\n",
      "\t\t\t\t28,\r\n",
      "\t\t\t\t30,\r\n",
      "\t\t\t\t32\r\n",
      "\t\t\t],\r\n",
      "\t\t\t\"name\": \"OUTPUT0\",\r\n",
      "\t\t\t\"shape\": [\r\n",
      "\t\t\t\t1,\r\n",
      "\t\t\t\t16\r\n",
      "\t\t\t],\r\n",
      "\t\t\t\"datatype\": \"INT32\"\r\n",
      "\t\t},\r\n",
      "\t\t{\r\n",
      "\t\t\t\"data\": [\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0\r\n",
      "\t\t\t],\r\n",
      "\t\t\t\"name\": \"OUTPUT1\",\r\n",
      "\t\t\t\"shape\": [\r\n",
      "\t\t\t\t1,\r\n",
      "\t\t\t\t16\r\n",
      "\t\t\t],\r\n",
      "\t\t\t\"datatype\": \"INT32\"\r\n",
      "\t\t}\r\n",
      "\t]\r\n",
      "}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline infer tfsimple --header x-request-id=test-id \\\n",
    "    '{\"inputs\":[{\"name\":\"INPUT0\",\"data\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],\"datatype\":\"INT32\",\"shape\":[1,16]},{\"name\":\"INPUT1\",\"data\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],\"datatype\":\"INT32\",\"shape\":[1,16]}]}' "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "id": "7e943b73",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "seldon.default.model.tfsimple1.inputs\ttest-id\t{\"inputs\":[{\"name\":\"INPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]}}, {\"name\":\"INPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]}}]}\r\n",
      "seldon.default.model.tfsimple1.outputs\ttest-id\t{\"modelName\":\"tfsimple1_1\", \"modelVersion\":\"1\", \"outputs\":[{\"name\":\"OUTPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}, {\"name\":\"OUTPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}}]}\r\n",
      "seldon.default.pipeline.tfsimple.inputs\ttest-id\t{\"inputs\":[{\"name\":\"INPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]}}, {\"name\":\"INPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]}}]}\r\n",
      "seldon.default.pipeline.tfsimple.outputs\ttest-id\t{\"outputs\":[{\"name\":\"OUTPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}, {\"name\":\"OUTPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}}]}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline inspect tfsimple"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "id": "46db0594",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "seldon.default.model.tfsimple2.inputs\ttest-id\t{\"inputs\":[{\"name\":\"INPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}, {\"name\":\"INPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}}], \"rawInputContents\":[\"AgAAAAQAAAAGAAAACAAAAAoAAAAMAAAADgAAABAAAAASAAAAFAAAABYAAAAYAAAAGgAAABwAAAAeAAAAIAAAAA==\", \"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==\"]}\r\n",
      "seldon.default.model.tfsimple2.outputs\ttest-id\t{\"modelName\":\"tfsimple2_1\", \"modelVersion\":\"1\", \"outputs\":[{\"name\":\"OUTPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}, {\"name\":\"OUTPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}]}\r\n",
      "seldon.default.pipeline.tfsimple-extended.inputs\ttest-id\t{\"inputs\":[{\"name\":\"INPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}, {\"name\":\"INPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}}], \"rawInputContents\":[\"AgAAAAQAAAAGAAAACAAAAAoAAAAMAAAADgAAABAAAAASAAAAFAAAABYAAAAYAAAAGgAAABwAAAAeAAAAIAAAAA==\", \"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==\"]}\r\n",
      "seldon.default.pipeline.tfsimple-extended.outputs\ttest-id\t{\"outputs\":[{\"name\":\"OUTPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}, {\"name\":\"OUTPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}]}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline inspect tfsimple-extended"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "id": "dimensional-hours",
   "metadata": {},
   "outputs": [],
   "source": [
    "!seldon pipeline unload tfsimple-extended\n",
    "!seldon pipeline unload tfsimple"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "id": "outside-inspiration",
   "metadata": {},
   "outputs": [],
   "source": [
    "!seldon model unload tfsimple1\n",
    "!seldon model unload tfsimple2"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ca596799",
   "metadata": {},
   "source": [
    "### Pipeline pulling from two other Pipelines\n",
    "\n",
    "![pipeline-to-pipeline](img_pipeline2.jpg)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "id": "2080d433",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "apiVersion: mlops.seldon.io/v1alpha1\n",
      "kind: Model\n",
      "metadata:\n",
      "  name: tfsimple1\n",
      "spec:\n",
      "  storageUri: \"gs://seldon-models/triton/simple\"\n",
      "  requirements:\n",
      "  - tensorflow\n",
      "  memory: 100Ki\n",
      "apiVersion: mlops.seldon.io/v1alpha1\n",
      "kind: Model\n",
      "metadata:\n",
      "  name: tfsimple2\n",
      "spec:\n",
      "  storageUri: \"gs://seldon-models/triton/simple\"\n",
      "  requirements:\n",
      "  - tensorflow\n",
      "  memory: 100Ki\n"
     ]
    }
   ],
   "source": [
    "!cat ./models/tfsimple1.yaml\n",
    "!cat ./models/tfsimple2.yaml"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "id": "bd345e86",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{}\n",
      "{}\n"
     ]
    }
   ],
   "source": [
    "!seldon model load -f ./models/tfsimple1.yaml \n",
    "!seldon model load -f ./models/tfsimple2.yaml "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "id": "5cf517d3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{}\n",
      "{}\n"
     ]
    }
   ],
   "source": [
    "!seldon model status tfsimple1 -w ModelAvailable | jq -M .\n",
    "!seldon model status tfsimple2 -w ModelAvailable | jq -M ."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 97,
   "id": "61230cb9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "apiVersion: mlops.seldon.io/v1alpha1\r\n",
      "kind: Pipeline\r\n",
      "metadata:\r\n",
      "  name: tfsimple\r\n",
      "spec:\r\n",
      "  steps:\r\n",
      "    - name: tfsimple1\r\n",
      "  output:\r\n",
      "    steps:\r\n",
      "    - tfsimple1\r\n"
     ]
    }
   ],
   "source": [
    "!cat ./pipelines/tfsimple.yaml"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "id": "3ddcd6c1",
   "metadata": {},
   "outputs": [],
   "source": [
    "!seldon pipeline load -f ./pipelines/tfsimple.yaml"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "id": "761c6bbd",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\r\n",
      "  \"pipelineName\": \"tfsimple\",\r\n",
      "  \"versions\": [\r\n",
      "    {\r\n",
      "      \"pipeline\": {\r\n",
      "        \"name\": \"tfsimple\",\r\n",
      "        \"uid\": \"cieq6aai8ufs73flaj5g\",\r\n",
      "        \"version\": 1,\r\n",
      "        \"steps\": [\r\n",
      "          {\r\n",
      "            \"name\": \"tfsimple1\"\r\n",
      "          }\r\n",
      "        ],\r\n",
      "        \"output\": {\r\n",
      "          \"steps\": [\r\n",
      "            \"tfsimple1.outputs\"\r\n",
      "          ]\r\n",
      "        },\r\n",
      "        \"kubernetesMeta\": {}\r\n",
      "      },\r\n",
      "      \"state\": {\r\n",
      "        \"pipelineVersion\": 1,\r\n",
      "        \"status\": \"PipelineReady\",\r\n",
      "        \"reason\": \"created pipeline\",\r\n",
      "        \"lastChangeTimestamp\": \"2023-06-29T15:28:41.766794892Z\",\r\n",
      "        \"modelsReady\": true\r\n",
      "      }\r\n",
      "    }\r\n",
      "  ]\r\n",
      "}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline status tfsimple -w PipelineReady | jq -M ."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "id": "7ac2e813",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\r\n",
      "  \"model_name\": \"\",\r\n",
      "  \"outputs\": [\r\n",
      "    {\r\n",
      "      \"data\": [\r\n",
      "        2,\r\n",
      "        4,\r\n",
      "        6,\r\n",
      "        8,\r\n",
      "        10,\r\n",
      "        12,\r\n",
      "        14,\r\n",
      "        16,\r\n",
      "        18,\r\n",
      "        20,\r\n",
      "        22,\r\n",
      "        24,\r\n",
      "        26,\r\n",
      "        28,\r\n",
      "        30,\r\n",
      "        32\r\n",
      "      ],\r\n",
      "      \"name\": \"OUTPUT0\",\r\n",
      "      \"shape\": [\r\n",
      "        1,\r\n",
      "        16\r\n",
      "      ],\r\n",
      "      \"datatype\": \"INT32\"\r\n",
      "    },\r\n",
      "    {\r\n",
      "      \"data\": [\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0\r\n",
      "      ],\r\n",
      "      \"name\": \"OUTPUT1\",\r\n",
      "      \"shape\": [\r\n",
      "        1,\r\n",
      "        16\r\n",
      "      ],\r\n",
      "      \"datatype\": \"INT32\"\r\n",
      "    }\r\n",
      "  ]\r\n",
      "}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline infer tfsimple \\\n",
    "    '{\"inputs\":[{\"name\":\"INPUT0\",\"data\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],\"datatype\":\"INT32\",\"shape\":[1,16]},{\"name\":\"INPUT1\",\"data\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],\"datatype\":\"INT32\",\"shape\":[1,16]}]}' | jq -M ."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 101,
   "id": "ae92d1db",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "apiVersion: mlops.seldon.io/v1alpha1\n",
      "kind: Pipeline\n",
      "metadata:\n",
      "  name: tfsimple-extended\n",
      "spec:\n",
      "  input:\n",
      "    externalInputs:\n",
      "      - tfsimple.outputs\n",
      "    tensorMap:\n",
      "      tfsimple.outputs.OUTPUT0: INPUT0\n",
      "      tfsimple.outputs.OUTPUT1: INPUT1\n",
      "  steps:\n",
      "    - name: tfsimple2\n",
      "  output:\n",
      "    steps:\n",
      "    - tfsimple2\n",
      "---\n",
      "apiVersion: mlops.seldon.io/v1alpha1\n",
      "kind: Pipeline\n",
      "metadata:\n",
      "  name: tfsimple-extended2\n",
      "spec:\n",
      "  input:\n",
      "    externalInputs:\n",
      "      - tfsimple.outputs\n",
      "    tensorMap:\n",
      "      tfsimple.outputs.OUTPUT0: INPUT0\n",
      "      tfsimple.outputs.OUTPUT1: INPUT1\n",
      "  steps:\n",
      "    - name: tfsimple2\n",
      "  output:\n",
      "    steps:\n",
      "    - tfsimple2\n",
      "---\n",
      "apiVersion: mlops.seldon.io/v1alpha1\n",
      "kind: Pipeline\n",
      "metadata:\n",
      "  name: tfsimple-combined\n",
      "spec:\n",
      "  input:\n",
      "    externalInputs:\n",
      "      - tfsimple-extended.outputs.OUTPUT0\n",
      "      - tfsimple-extended2.outputs.OUTPUT1\n",
      "    tensorMap:\n",
      "      tfsimple-extended.outputs.OUTPUT0: INPUT0\n",
      "      tfsimple-extended2.outputs.OUTPUT1: INPUT1\n",
      "  steps:\n",
      "    - name: tfsimple2\n",
      "  output:\n",
      "    steps:\n",
      "    - tfsimple2\n"
     ]
    }
   ],
   "source": [
    "!cat ./pipelines/tfsimple-extended.yaml\n",
    "!echo \"---\"\n",
    "!cat ./pipelines/tfsimple-extended2.yaml\n",
    "!echo \"---\"\n",
    "!cat ./pipelines/tfsimple-combined.yaml"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "id": "0aca3e43",
   "metadata": {},
   "outputs": [],
   "source": [
    "!seldon pipeline load -f ./pipelines/tfsimple-extended.yaml\n",
    "!seldon pipeline load -f ./pipelines/tfsimple-extended2.yaml\n",
    "!seldon pipeline load -f ./pipelines/tfsimple-combined.yaml"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "id": "5a3cfc5d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\"pipelineName\":\"tfsimple-extended\", \"versions\":[{\"pipeline\":{\"name\":\"tfsimple-extended\", \"uid\":\"cieq6dai8ufs73flaj60\", \"version\":1, \"steps\":[{\"name\":\"tfsimple2\"}], \"output\":{\"steps\":[\"tfsimple2.outputs\"]}, \"kubernetesMeta\":{}, \"input\":{\"externalInputs\":[\"tfsimple.outputs\"], \"tensorMap\":{\"tfsimple.outputs.OUTPUT0\":\"INPUT0\", \"tfsimple.outputs.OUTPUT1\":\"INPUT1\"}}}, \"state\":{\"pipelineVersion\":1, \"status\":\"PipelineReady\", \"reason\":\"created pipeline\", \"lastChangeTimestamp\":\"2023-06-29T15:28:53.963808852Z\", \"modelsReady\":true}}]}\n",
      "{\"pipelineName\":\"tfsimple-extended2\", \"versions\":[{\"pipeline\":{\"name\":\"tfsimple-extended2\", \"uid\":\"cieq6dai8ufs73flaj6g\", \"version\":1, \"steps\":[{\"name\":\"tfsimple2\"}], \"output\":{\"steps\":[\"tfsimple2.outputs\"]}, \"kubernetesMeta\":{}, \"input\":{\"externalInputs\":[\"tfsimple.outputs\"], \"tensorMap\":{\"tfsimple.outputs.OUTPUT0\":\"INPUT0\", \"tfsimple.outputs.OUTPUT1\":\"INPUT1\"}}}, \"state\":{\"pipelineVersion\":1, \"status\":\"PipelineReady\", \"reason\":\"created pipeline\", \"lastChangeTimestamp\":\"2023-06-29T15:28:54.087670106Z\", \"modelsReady\":true}}]}\n",
      "{\"pipelineName\":\"tfsimple-combined\", \"versions\":[{\"pipeline\":{\"name\":\"tfsimple-combined\", \"uid\":\"cieq6dii8ufs73flaj70\", \"version\":1, \"steps\":[{\"name\":\"tfsimple2\"}], \"output\":{\"steps\":[\"tfsimple2.outputs\"]}, \"kubernetesMeta\":{}, \"input\":{\"externalInputs\":[\"tfsimple-extended.outputs.OUTPUT0\", \"tfsimple-extended2.outputs.OUTPUT1\"], \"tensorMap\":{\"tfsimple-extended.outputs.OUTPUT0\":\"INPUT0\", \"tfsimple-extended2.outputs.OUTPUT1\":\"INPUT1\"}}}, \"state\":{\"pipelineVersion\":1, \"status\":\"PipelineReady\", \"reason\":\"created pipeline\", \"lastChangeTimestamp\":\"2023-06-29T15:28:54.330770841Z\", \"modelsReady\":true}}]}\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline status tfsimple-extended -w PipelineReady\n",
    "!seldon pipeline status tfsimple-extended2 -w PipelineReady\n",
    "!seldon pipeline status tfsimple-combined -w PipelineReady"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 113,
   "id": "6d48a725",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\r\n",
      "\t\"model_name\": \"\",\r\n",
      "\t\"outputs\": [\r\n",
      "\t\t{\r\n",
      "\t\t\t\"data\": [\r\n",
      "\t\t\t\t2,\r\n",
      "\t\t\t\t4,\r\n",
      "\t\t\t\t6,\r\n",
      "\t\t\t\t8,\r\n",
      "\t\t\t\t10,\r\n",
      "\t\t\t\t12,\r\n",
      "\t\t\t\t14,\r\n",
      "\t\t\t\t16,\r\n",
      "\t\t\t\t18,\r\n",
      "\t\t\t\t20,\r\n",
      "\t\t\t\t22,\r\n",
      "\t\t\t\t24,\r\n",
      "\t\t\t\t26,\r\n",
      "\t\t\t\t28,\r\n",
      "\t\t\t\t30,\r\n",
      "\t\t\t\t32\r\n",
      "\t\t\t],\r\n",
      "\t\t\t\"name\": \"OUTPUT0\",\r\n",
      "\t\t\t\"shape\": [\r\n",
      "\t\t\t\t1,\r\n",
      "\t\t\t\t16\r\n",
      "\t\t\t],\r\n",
      "\t\t\t\"datatype\": \"INT32\"\r\n",
      "\t\t},\r\n",
      "\t\t{\r\n",
      "\t\t\t\"data\": [\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0\r\n",
      "\t\t\t],\r\n",
      "\t\t\t\"name\": \"OUTPUT1\",\r\n",
      "\t\t\t\"shape\": [\r\n",
      "\t\t\t\t1,\r\n",
      "\t\t\t\t16\r\n",
      "\t\t\t],\r\n",
      "\t\t\t\"datatype\": \"INT32\"\r\n",
      "\t\t}\r\n",
      "\t]\r\n",
      "}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline infer tfsimple --header x-request-id=test-id2 \\\n",
    "    '{\"inputs\":[{\"name\":\"INPUT0\",\"data\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],\"datatype\":\"INT32\",\"shape\":[1,16]},{\"name\":\"INPUT1\",\"data\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],\"datatype\":\"INT32\",\"shape\":[1,16]}]}' "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 114,
   "id": "2232df0c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "seldon.default.model.tfsimple1.inputs\ttest-id2\t{\"inputs\":[{\"name\":\"INPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]}}, {\"name\":\"INPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]}}]}\r\n",
      "seldon.default.model.tfsimple1.outputs\ttest-id2\t{\"modelName\":\"tfsimple1_1\", \"modelVersion\":\"1\", \"outputs\":[{\"name\":\"OUTPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}, {\"name\":\"OUTPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}}]}\r\n",
      "seldon.default.pipeline.tfsimple.inputs\ttest-id2\t{\"inputs\":[{\"name\":\"INPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]}}, {\"name\":\"INPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]}}]}\r\n",
      "seldon.default.pipeline.tfsimple.outputs\ttest-id2\t{\"outputs\":[{\"name\":\"OUTPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}, {\"name\":\"OUTPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}}]}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline inspect tfsimple"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 115,
   "id": "b583fc48",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "seldon.default.model.tfsimple2.inputs\ttest-id2\t{\"inputs\":[{\"name\":\"INPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}, {\"name\":\"INPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}}], \"rawInputContents\":[\"AgAAAAQAAAAGAAAACAAAAAoAAAAMAAAADgAAABAAAAASAAAAFAAAABYAAAAYAAAAGgAAABwAAAAeAAAAIAAAAA==\", \"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==\"]}\t\tx-request-id=[test-id2]\tx-forwarded-proto=[http]\tx-seldon-route=[:tfsimple1_1:]\tx-envoy-upstream-service-time=[1]\tpipeline=[tfsimple-extended]\ttraceparent=[00-e438b82ad361ac2d5481bcfc494074d2-e468d06afdab8f52-01]\tx-envoy-expected-rq-timeout-ms=[60000]\r\n",
      "seldon.default.model.tfsimple2.outputs\ttest-id2\t{\"modelName\":\"tfsimple2_1\", \"modelVersion\":\"1\", \"outputs\":[{\"name\":\"OUTPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}, {\"name\":\"OUTPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}]}\t\tx-envoy-expected-rq-timeout-ms=[60000]\tx-request-id=[test-id2]\tx-forwarded-proto=[http]\tx-seldon-route=[:tfsimple1_1: :tfsimple2_1:]\tx-envoy-upstream-service-time=[1]\tpipeline=[tfsimple-extended]\ttraceparent=[00-e438b82ad361ac2d5481bcfc494074d2-73bd1ee54a94d8fb-01]\r\n",
      "seldon.default.pipeline.tfsimple-extended.inputs\ttest-id\t{\"inputs\":[{\"name\":\"INPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}, {\"name\":\"INPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}}], \"rawInputContents\":[\"AgAAAAQAAAAGAAAACAAAAAoAAAAMAAAADgAAABAAAAASAAAAFAAAABYAAAAYAAAAGgAAABwAAAAeAAAAIAAAAA==\", \"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==\"]}\t\tpipeline=[tfsimple-extended]\ttraceparent=[00-3a6047efa647efc2b3fc5266ae023d23-fee12926788ce3b6-01]\tx-envoy-expected-rq-timeout-ms=[60000]\tx-request-id=[test-id]\tx-forwarded-proto=[http]\tx-envoy-upstream-service-time=[5]\tx-seldon-route=[:tfsimple1_1:]\r\n",
      "seldon.default.pipeline.tfsimple-extended.inputs\ttest-id2\t{\"inputs\":[{\"name\":\"INPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}, {\"name\":\"INPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}}], \"rawInputContents\":[\"AgAAAAQAAAAGAAAACAAAAAoAAAAMAAAADgAAABAAAAASAAAAFAAAABYAAAAYAAAAGgAAABwAAAAeAAAAIAAAAA==\", \"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==\"]}\t\tx-forwarded-proto=[http]\tx-seldon-route=[:tfsimple1_1:]\tx-envoy-upstream-service-time=[1]\tpipeline=[tfsimple-extended]\ttraceparent=[00-e438b82ad361ac2d5481bcfc494074d2-4df8459a992e0278-01]\tx-envoy-expected-rq-timeout-ms=[60000]\tx-request-id=[test-id2]\r\n",
      "seldon.default.pipeline.tfsimple-extended.outputs\ttest-id\t{\"outputs\":[{\"name\":\"OUTPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}, {\"name\":\"OUTPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}]}\t\tpipeline=[tfsimple-extended]\ttraceparent=[00-3a6047efa647efc2b3fc5266ae023d23-b2f899a739c5cafd-01]\tx-envoy-expected-rq-timeout-ms=[60000]\tx-request-id=[test-id]\tx-forwarded-proto=[http]\tx-envoy-upstream-service-time=[5]\tx-seldon-route=[:tfsimple1_1: :tfsimple2_1:]\r\n",
      "seldon.default.pipeline.tfsimple-extended.outputs\ttest-id2\t{\"outputs\":[{\"name\":\"OUTPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}, {\"name\":\"OUTPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}]}\t\tx-envoy-upstream-service-time=[1]\tpipeline=[tfsimple-extended]\ttraceparent=[00-e438b82ad361ac2d5481bcfc494074d2-dfa399143feec23d-01]\tx-envoy-expected-rq-timeout-ms=[60000]\tx-request-id=[test-id2]\tx-forwarded-proto=[http]\tx-seldon-route=[:tfsimple1_1: :tfsimple2_1:]\r\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline inspect tfsimple-extended --offset 2 --verbose"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "id": "4da09374",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "seldon.default.pipeline.tfsimple-extended2.inputs\ttest-id3\t{\"inputs\":[{\"name\":\"INPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}, {\"name\":\"INPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}}], \"rawInputContents\":[\"AgAAAAQAAAAGAAAACAAAAAoAAAAMAAAADgAAABAAAAASAAAAFAAAABYAAAAYAAAAGgAAABwAAAAeAAAAIAAAAA==\", \"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==\"]}\r\n",
      "seldon.default.pipeline.tfsimple-extended2.inputs\ttest-id\t{\"inputs\":[{\"name\":\"INPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}, {\"name\":\"INPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}}], \"rawInputContents\":[\"AgAAAAQAAAAGAAAACAAAAAoAAAAMAAAADgAAABAAAAASAAAAFAAAABYAAAAYAAAAGgAAABwAAAAeAAAAIAAAAA==\", \"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==\"]}\r\n",
      "seldon.default.pipeline.tfsimple-extended2.outputs\ttest-id3\t{\"outputs\":[{\"name\":\"OUTPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}, {\"name\":\"OUTPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}]}\r\n",
      "seldon.default.pipeline.tfsimple-extended2.outputs\ttest-id\t{\"outputs\":[{\"name\":\"OUTPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}, {\"name\":\"OUTPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}]}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline inspect tfsimple-extended2 --offset 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "id": "95fe7d91",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "seldon.default.model.tfsimple2.inputs\ttest-id\t{\"inputs\":[{\"name\":\"INPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}, {\"name\":\"INPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}], \"rawInputContents\":[\"AgAAAAQAAAAGAAAACAAAAAoAAAAMAAAADgAAABAAAAASAAAAFAAAABYAAAAYAAAAGgAAABwAAAAeAAAAIAAAAA==\", \"AgAAAAQAAAAGAAAACAAAAAoAAAAMAAAADgAAABAAAAASAAAAFAAAABYAAAAYAAAAGgAAABwAAAAeAAAAIAAAAA==\"]}\r\n",
      "seldon.default.model.tfsimple2.outputs\ttest-id\t{\"modelName\":\"tfsimple2_1\", \"modelVersion\":\"1\", \"outputs\":[{\"name\":\"OUTPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64]}}, {\"name\":\"OUTPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}}]}\r\n",
      "seldon.default.pipeline.tfsimple-combined.inputs\ttest-id\t{\"inputs\":[{\"name\":\"INPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}, {\"name\":\"INPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}], \"rawInputContents\":[\"AgAAAAQAAAAGAAAACAAAAAoAAAAMAAAADgAAABAAAAASAAAAFAAAABYAAAAYAAAAGgAAABwAAAAeAAAAIAAAAA==\", \"AgAAAAQAAAAGAAAACAAAAAoAAAAMAAAADgAAABAAAAASAAAAFAAAABYAAAAYAAAAGgAAABwAAAAeAAAAIAAAAA==\"]}\r\n",
      "seldon.default.pipeline.tfsimple-combined.outputs\ttest-id\t{\"outputs\":[{\"name\":\"OUTPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64]}}, {\"name\":\"OUTPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}}]}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline inspect tfsimple-combined"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "7baed85b",
   "metadata": {},
   "outputs": [],
   "source": [
    "!seldon pipeline unload tfsimple-extended\n",
    "!seldon pipeline unload tfsimple-extended2\n",
    "!seldon pipeline unload tfsimple-combined\n",
    "!seldon pipeline unload tfsimple"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "e4e9c31c",
   "metadata": {},
   "outputs": [],
   "source": [
    "!seldon model unload tfsimple1\n",
    "!seldon model unload tfsimple2"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6e0ece15",
   "metadata": {},
   "source": [
    "### Pipeline pullin from one pipeline with a trigger to another\n",
    "\n",
    "![pipeline-to-pipeline](img_pipeline3.jpg)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "2edfe335",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "apiVersion: mlops.seldon.io/v1alpha1\n",
      "kind: Model\n",
      "metadata:\n",
      "  name: tfsimple1\n",
      "spec:\n",
      "  storageUri: \"gs://seldon-models/triton/simple\"\n",
      "  requirements:\n",
      "  - tensorflow\n",
      "  memory: 100Ki\n",
      "apiVersion: mlops.seldon.io/v1alpha1\n",
      "kind: Model\n",
      "metadata:\n",
      "  name: tfsimple2\n",
      "spec:\n",
      "  storageUri: \"gs://seldon-models/triton/simple\"\n",
      "  requirements:\n",
      "  - tensorflow\n",
      "  memory: 100Ki\n"
     ]
    }
   ],
   "source": [
    "!cat ./models/tfsimple1.yaml\n",
    "!cat ./models/tfsimple2.yaml"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "2cb492ce",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{}\n",
      "{}\n"
     ]
    }
   ],
   "source": [
    "!seldon model load -f ./models/tfsimple1.yaml \n",
    "!seldon model load -f ./models/tfsimple2.yaml "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "61177684",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{}\n",
      "{}\n"
     ]
    }
   ],
   "source": [
    "!seldon model status tfsimple1 -w ModelAvailable | jq -M .\n",
    "!seldon model status tfsimple2 -w ModelAvailable | jq -M ."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "2f05e948",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "apiVersion: mlops.seldon.io/v1alpha1\r\n",
      "kind: Pipeline\r\n",
      "metadata:\r\n",
      "  name: tfsimple\r\n",
      "spec:\r\n",
      "  steps:\r\n",
      "    - name: tfsimple1\r\n",
      "  output:\r\n",
      "    steps:\r\n",
      "    - tfsimple1\r\n"
     ]
    }
   ],
   "source": [
    "!cat ./pipelines/tfsimple.yaml"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "d51beb10",
   "metadata": {},
   "outputs": [],
   "source": [
    "!seldon pipeline load -f ./pipelines/tfsimple.yaml"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "754b5288",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\r\n",
      "  \"pipelineName\": \"tfsimple\",\r\n",
      "  \"versions\": [\r\n",
      "    {\r\n",
      "      \"pipeline\": {\r\n",
      "        \"name\": \"tfsimple\",\r\n",
      "        \"uid\": \"ciepkmii8ufs73flaj2g\",\r\n",
      "        \"version\": 1,\r\n",
      "        \"steps\": [\r\n",
      "          {\r\n",
      "            \"name\": \"tfsimple1\"\r\n",
      "          }\r\n",
      "        ],\r\n",
      "        \"output\": {\r\n",
      "          \"steps\": [\r\n",
      "            \"tfsimple1.outputs\"\r\n",
      "          ]\r\n",
      "        },\r\n",
      "        \"kubernetesMeta\": {}\r\n",
      "      },\r\n",
      "      \"state\": {\r\n",
      "        \"pipelineVersion\": 1,\r\n",
      "        \"status\": \"PipelineReady\",\r\n",
      "        \"reason\": \"created pipeline\",\r\n",
      "        \"lastChangeTimestamp\": \"2023-06-29T14:51:06.822716088Z\",\r\n",
      "        \"modelsReady\": true\r\n",
      "      }\r\n",
      "    }\r\n",
      "  ]\r\n",
      "}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline status tfsimple -w PipelineReady | jq -M ."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "cf723042",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\r\n",
      "  \"model_name\": \"\",\r\n",
      "  \"outputs\": [\r\n",
      "    {\r\n",
      "      \"data\": [\r\n",
      "        2,\r\n",
      "        4,\r\n",
      "        6,\r\n",
      "        8,\r\n",
      "        10,\r\n",
      "        12,\r\n",
      "        14,\r\n",
      "        16,\r\n",
      "        18,\r\n",
      "        20,\r\n",
      "        22,\r\n",
      "        24,\r\n",
      "        26,\r\n",
      "        28,\r\n",
      "        30,\r\n",
      "        32\r\n",
      "      ],\r\n",
      "      \"name\": \"OUTPUT0\",\r\n",
      "      \"shape\": [\r\n",
      "        1,\r\n",
      "        16\r\n",
      "      ],\r\n",
      "      \"datatype\": \"INT32\"\r\n",
      "    },\r\n",
      "    {\r\n",
      "      \"data\": [\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0\r\n",
      "      ],\r\n",
      "      \"name\": \"OUTPUT1\",\r\n",
      "      \"shape\": [\r\n",
      "        1,\r\n",
      "        16\r\n",
      "      ],\r\n",
      "      \"datatype\": \"INT32\"\r\n",
      "    }\r\n",
      "  ]\r\n",
      "}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline infer tfsimple \\\n",
    "    '{\"inputs\":[{\"name\":\"INPUT0\",\"data\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],\"datatype\":\"INT32\",\"shape\":[1,16]},{\"name\":\"INPUT1\",\"data\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],\"datatype\":\"INT32\",\"shape\":[1,16]}]}' | jq -M ."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "54d4d628",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "apiVersion: mlops.seldon.io/v1alpha1\n",
      "kind: Pipeline\n",
      "metadata:\n",
      "  name: tfsimple-extended\n",
      "spec:\n",
      "  input:\n",
      "    externalInputs:\n",
      "      - tfsimple.outputs\n",
      "    tensorMap:\n",
      "      tfsimple.outputs.OUTPUT0: INPUT0\n",
      "      tfsimple.outputs.OUTPUT1: INPUT1\n",
      "  steps:\n",
      "    - name: tfsimple2\n",
      "  output:\n",
      "    steps:\n",
      "    - tfsimple2\n",
      "---\n",
      "apiVersion: mlops.seldon.io/v1alpha1\n",
      "kind: Pipeline\n",
      "metadata:\n",
      "  name: tfsimple-extended2\n",
      "spec:\n",
      "  input:\n",
      "    externalInputs:\n",
      "      - tfsimple.outputs\n",
      "    tensorMap:\n",
      "      tfsimple.outputs.OUTPUT0: INPUT0\n",
      "      tfsimple.outputs.OUTPUT1: INPUT1\n",
      "  steps:\n",
      "    - name: tfsimple2\n",
      "  output:\n",
      "    steps:\n",
      "    - tfsimple2\n",
      "---\n",
      "apiVersion: mlops.seldon.io/v1alpha1\n",
      "kind: Pipeline\n",
      "metadata:\n",
      "  name: tfsimple-combined-trigger\n",
      "spec:\n",
      "  input:\n",
      "    externalInputs:\n",
      "      - tfsimple-extended.outputs\n",
      "    externalTriggers:\n",
      "      - tfsimple-extended2.outputs\n",
      "    tensorMap:\n",
      "      tfsimple-extended.outputs.OUTPUT0: INPUT0\n",
      "      tfsimple-extended.outputs.OUTPUT1: INPUT1\n",
      "  steps:\n",
      "    - name: tfsimple2\n",
      "  output:\n",
      "    steps:\n",
      "    - tfsimple2\n"
     ]
    }
   ],
   "source": [
    "!cat ./pipelines/tfsimple-extended.yaml\n",
    "!echo \"---\"\n",
    "!cat ./pipelines/tfsimple-extended2.yaml\n",
    "!echo \"---\"\n",
    "!cat ./pipelines/tfsimple-combined-trigger.yaml"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "3d8db4fd",
   "metadata": {},
   "outputs": [],
   "source": [
    "!seldon pipeline load -f ./pipelines/tfsimple-extended.yaml\n",
    "!seldon pipeline load -f ./pipelines/tfsimple-extended2.yaml\n",
    "!seldon pipeline load -f ./pipelines/tfsimple-combined-trigger.yaml"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "1bb001e4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\"pipelineName\":\"tfsimple-extended\", \"versions\":[{\"pipeline\":{\"name\":\"tfsimple-extended\", \"uid\":\"ciepkoii8ufs73flaj30\", \"version\":1, \"steps\":[{\"name\":\"tfsimple2\"}], \"output\":{\"steps\":[\"tfsimple2.outputs\"]}, \"kubernetesMeta\":{}, \"input\":{\"externalInputs\":[\"tfsimple.outputs\"], \"tensorMap\":{\"tfsimple.outputs.OUTPUT0\":\"INPUT0\", \"tfsimple.outputs.OUTPUT1\":\"INPUT1\"}}}, \"state\":{\"pipelineVersion\":1, \"status\":\"PipelineReady\", \"reason\":\"created pipeline\", \"lastChangeTimestamp\":\"2023-06-29T14:51:14.937544974Z\", \"modelsReady\":true}}]}\n",
      "{\"pipelineName\":\"tfsimple-extended2\", \"versions\":[{\"pipeline\":{\"name\":\"tfsimple-extended2\", \"uid\":\"ciepkoii8ufs73flaj3g\", \"version\":1, \"steps\":[{\"name\":\"tfsimple2\"}], \"output\":{\"steps\":[\"tfsimple2.outputs\"]}, \"kubernetesMeta\":{}, \"input\":{\"externalInputs\":[\"tfsimple.outputs\"], \"tensorMap\":{\"tfsimple.outputs.OUTPUT0\":\"INPUT0\", \"tfsimple.outputs.OUTPUT1\":\"INPUT1\"}}}, \"state\":{\"pipelineVersion\":1, \"status\":\"PipelineReady\", \"reason\":\"created pipeline\", \"lastChangeTimestamp\":\"2023-06-29T14:51:15.062097751Z\", \"modelsReady\":true}}]}\n",
      "{\"pipelineName\":\"tfsimple-combined-trigger\", \"versions\":[{\"pipeline\":{\"name\":\"tfsimple-combined-trigger\", \"uid\":\"ciepkoqi8ufs73flaj40\", \"version\":1, \"steps\":[{\"name\":\"tfsimple2\"}], \"output\":{\"steps\":[\"tfsimple2.outputs\"]}, \"kubernetesMeta\":{}, \"input\":{\"externalInputs\":[\"tfsimple-extended.outputs\"], \"externalTriggers\":[\"tfsimple-extended2.outputs\"], \"tensorMap\":{\"tfsimple-extended.outputs.OUTPUT0\":\"INPUT0\", \"tfsimple-extended.outputs.OUTPUT1\":\"INPUT1\"}}}, \"state\":{\"pipelineVersion\":1, \"status\":\"PipelineReady\", \"reason\":\"created pipeline\", \"lastChangeTimestamp\":\"2023-06-29T14:51:15.326170068Z\", \"modelsReady\":true}}]}\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline status tfsimple-extended -w PipelineReady\n",
    "!seldon pipeline status tfsimple-extended2 -w PipelineReady\n",
    "!seldon pipeline status tfsimple-combined-trigger -w PipelineReady"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "dac6c62c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\r\n",
      "\t\"model_name\": \"\",\r\n",
      "\t\"outputs\": [\r\n",
      "\t\t{\r\n",
      "\t\t\t\"data\": [\r\n",
      "\t\t\t\t2,\r\n",
      "\t\t\t\t4,\r\n",
      "\t\t\t\t6,\r\n",
      "\t\t\t\t8,\r\n",
      "\t\t\t\t10,\r\n",
      "\t\t\t\t12,\r\n",
      "\t\t\t\t14,\r\n",
      "\t\t\t\t16,\r\n",
      "\t\t\t\t18,\r\n",
      "\t\t\t\t20,\r\n",
      "\t\t\t\t22,\r\n",
      "\t\t\t\t24,\r\n",
      "\t\t\t\t26,\r\n",
      "\t\t\t\t28,\r\n",
      "\t\t\t\t30,\r\n",
      "\t\t\t\t32\r\n",
      "\t\t\t],\r\n",
      "\t\t\t\"name\": \"OUTPUT0\",\r\n",
      "\t\t\t\"shape\": [\r\n",
      "\t\t\t\t1,\r\n",
      "\t\t\t\t16\r\n",
      "\t\t\t],\r\n",
      "\t\t\t\"datatype\": \"INT32\"\r\n",
      "\t\t},\r\n",
      "\t\t{\r\n",
      "\t\t\t\"data\": [\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0\r\n",
      "\t\t\t],\r\n",
      "\t\t\t\"name\": \"OUTPUT1\",\r\n",
      "\t\t\t\"shape\": [\r\n",
      "\t\t\t\t1,\r\n",
      "\t\t\t\t16\r\n",
      "\t\t\t],\r\n",
      "\t\t\t\"datatype\": \"INT32\"\r\n",
      "\t\t}\r\n",
      "\t]\r\n",
      "}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline infer tfsimple --header x-request-id=test-id3 \\\n",
    "    '{\"inputs\":[{\"name\":\"INPUT0\",\"data\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],\"datatype\":\"INT32\",\"shape\":[1,16]},{\"name\":\"INPUT1\",\"data\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],\"datatype\":\"INT32\",\"shape\":[1,16]}]}' "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "965e5f92",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "seldon.default.model.tfsimple1.inputs\ttest-id3\t{\"inputs\":[{\"name\":\"INPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]}}, {\"name\":\"INPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]}}]}\r\n",
      "seldon.default.model.tfsimple1.outputs\ttest-id3\t{\"modelName\":\"tfsimple1_1\", \"modelVersion\":\"1\", \"outputs\":[{\"name\":\"OUTPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}, {\"name\":\"OUTPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}}]}\r\n",
      "seldon.default.pipeline.tfsimple.inputs\ttest-id3\t{\"inputs\":[{\"name\":\"INPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]}}, {\"name\":\"INPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]}}]}\r\n",
      "seldon.default.pipeline.tfsimple.outputs\ttest-id3\t{\"outputs\":[{\"name\":\"OUTPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}, {\"name\":\"OUTPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}}]}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline inspect tfsimple"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "079b4e27",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "seldon.default.model.tfsimple2.outputs\ttest-id3\t{\"modelName\":\"tfsimple2_1\", \"modelVersion\":\"1\", \"outputs\":[{\"name\":\"OUTPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}, {\"name\":\"OUTPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}]}\r\n",
      "seldon.default.pipeline.tfsimple-extended.inputs\ttest-id3\t{\"inputs\":[{\"name\":\"INPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}, {\"name\":\"INPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}}], \"rawInputContents\":[\"AgAAAAQAAAAGAAAACAAAAAoAAAAMAAAADgAAABAAAAASAAAAFAAAABYAAAAYAAAAGgAAABwAAAAeAAAAIAAAAA==\", \"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==\"]}\r\n",
      "seldon.default.pipeline.tfsimple-extended.inputs\ttest-id3\t{\"inputs\":[{\"name\":\"INPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}, {\"name\":\"INPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}}], \"rawInputContents\":[\"AgAAAAQAAAAGAAAACAAAAAoAAAAMAAAADgAAABAAAAASAAAAFAAAABYAAAAYAAAAGgAAABwAAAAeAAAAIAAAAA==\", \"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==\"]}\r\n",
      "seldon.default.pipeline.tfsimple-extended.outputs\ttest-id3\t{\"outputs\":[{\"name\":\"OUTPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}, {\"name\":\"OUTPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}]}\r\n",
      "seldon.default.pipeline.tfsimple-extended.outputs\ttest-id3\t{\"outputs\":[{\"name\":\"OUTPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}, {\"name\":\"OUTPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}]}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline inspect tfsimple-extended --offset 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "233f42f3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "seldon.default.model.tfsimple2.inputs\ttest-id3\t{\"inputs\":[{\"name\":\"INPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}, {\"name\":\"INPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}}], \"rawInputContents\":[\"AgAAAAQAAAAGAAAACAAAAAoAAAAMAAAADgAAABAAAAASAAAAFAAAABYAAAAYAAAAGgAAABwAAAAeAAAAIAAAAA==\", \"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==\"]}\r\n",
      "seldon.default.pipeline.tfsimple-extended2.inputs\ttest-id3\t{\"inputs\":[{\"name\":\"INPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}, {\"name\":\"INPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}}], \"rawInputContents\":[\"AgAAAAQAAAAGAAAACAAAAAoAAAAMAAAADgAAABAAAAASAAAAFAAAABYAAAAYAAAAGgAAABwAAAAeAAAAIAAAAA==\", \"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==\"]}\r\n",
      "seldon.default.pipeline.tfsimple-extended2.inputs\ttest-id3\t{\"inputs\":[{\"name\":\"INPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}, {\"name\":\"INPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}}], \"rawInputContents\":[\"AgAAAAQAAAAGAAAACAAAAAoAAAAMAAAADgAAABAAAAASAAAAFAAAABYAAAAYAAAAGgAAABwAAAAeAAAAIAAAAA==\", \"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==\"]}\r\n",
      "seldon.default.pipeline.tfsimple-extended2.outputs\ttest-id3\t{\"outputs\":[{\"name\":\"OUTPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}, {\"name\":\"OUTPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}]}\r\n",
      "seldon.default.pipeline.tfsimple-extended2.outputs\ttest-id3\t{\"outputs\":[{\"name\":\"OUTPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}, {\"name\":\"OUTPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}]}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline inspect tfsimple-extended2 --offset 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "e674c8d5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "seldon.default.model.tfsimple2.inputs\ttest-id3\t{\"inputs\":[{\"name\":\"INPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}, {\"name\":\"INPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}], \"rawInputContents\":[\"AgAAAAQAAAAGAAAACAAAAAoAAAAMAAAADgAAABAAAAASAAAAFAAAABYAAAAYAAAAGgAAABwAAAAeAAAAIAAAAA==\", \"AgAAAAQAAAAGAAAACAAAAAoAAAAMAAAADgAAABAAAAASAAAAFAAAABYAAAAYAAAAGgAAABwAAAAeAAAAIAAAAA==\"]}\r\n",
      "seldon.default.model.tfsimple2.outputs\ttest-id3\t{\"modelName\":\"tfsimple2_1\", \"modelVersion\":\"1\", \"outputs\":[{\"name\":\"OUTPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64]}}, {\"name\":\"OUTPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}}]}\r\n",
      "seldon.default.pipeline.tfsimple-combined-trigger.inputs\ttest-id3\t{\"inputs\":[{\"name\":\"INPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}, {\"name\":\"INPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]}}], \"rawInputContents\":[\"AgAAAAQAAAAGAAAACAAAAAoAAAAMAAAADgAAABAAAAASAAAAFAAAABYAAAAYAAAAGgAAABwAAAAeAAAAIAAAAA==\", \"AgAAAAQAAAAGAAAACAAAAAoAAAAMAAAADgAAABAAAAASAAAAFAAAABYAAAAYAAAAGgAAABwAAAAeAAAAIAAAAA==\"]}\r\n",
      "seldon.default.pipeline.tfsimple-combined-trigger.outputs\ttest-id3\t{\"outputs\":[{\"name\":\"OUTPUT0\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64]}}, {\"name\":\"OUTPUT1\", \"datatype\":\"INT32\", \"shape\":[\"1\", \"16\"], \"contents\":{\"intContents\":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}}]}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline inspect tfsimple-combined-trigger"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "id": "37e1399e",
   "metadata": {},
   "outputs": [],
   "source": [
    "!seldon pipeline unload tfsimple-extended\n",
    "!seldon pipeline unload tfsimple-extended2\n",
    "!seldon pipeline unload tfsimple-combined-trigger\n",
    "!seldon pipeline unload tfsimple"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "id": "81480753",
   "metadata": {},
   "outputs": [],
   "source": [
    "!seldon model unload tfsimple1\n",
    "!seldon model unload tfsimple2"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c2614d43",
   "metadata": {},
   "source": [
    "### Pipeline pulling from one other Pipeline Step\n",
    "\n",
    "![pipeline-to-pipeline](img_pipeline4.jpg)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "d006d9b2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "apiVersion: mlops.seldon.io/v1alpha1\n",
      "kind: Model\n",
      "metadata:\n",
      "  name: tfsimple1\n",
      "spec:\n",
      "  storageUri: \"gs://seldon-models/triton/simple\"\n",
      "  requirements:\n",
      "  - tensorflow\n",
      "  memory: 100Ki\n",
      "apiVersion: mlops.seldon.io/v1alpha1\n",
      "kind: Model\n",
      "metadata:\n",
      "  name: tfsimple2\n",
      "spec:\n",
      "  storageUri: \"gs://seldon-models/triton/simple\"\n",
      "  requirements:\n",
      "  - tensorflow\n",
      "  memory: 100Ki\n"
     ]
    }
   ],
   "source": [
    "!cat ./models/tfsimple1.yaml\n",
    "!cat ./models/tfsimple2.yaml"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "30f4ad48",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{}\n",
      "{}\n"
     ]
    }
   ],
   "source": [
    "!seldon model load -f ./models/tfsimple1.yaml \n",
    "!seldon model load -f ./models/tfsimple2.yaml "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "ae024817",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{}\n",
      "{}\n"
     ]
    }
   ],
   "source": [
    "!seldon model status tfsimple1 -w ModelAvailable | jq -M .\n",
    "!seldon model status tfsimple2 -w ModelAvailable | jq -M ."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "e180a273",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "apiVersion: mlops.seldon.io/v1alpha1\r\n",
      "kind: Pipeline\r\n",
      "metadata:\r\n",
      "  name: tfsimple\r\n",
      "spec:\r\n",
      "  steps:\r\n",
      "    - name: tfsimple1\r\n",
      "  output:\r\n",
      "    steps:\r\n",
      "    - tfsimple1\r\n"
     ]
    }
   ],
   "source": [
    "!cat ./pipelines/tfsimple.yaml"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "48dde798",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline load -f ./pipelines/tfsimple.yaml"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "77ee161a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\r\n",
      "  \"pipelineName\": \"tfsimple\",\r\n",
      "  \"versions\": [\r\n",
      "    {\r\n",
      "      \"pipeline\": {\r\n",
      "        \"name\": \"tfsimple\",\r\n",
      "        \"uid\": \"cg5g6m46dpcs73c4qhl0\",\r\n",
      "        \"version\": 1,\r\n",
      "        \"steps\": [\r\n",
      "          {\r\n",
      "            \"name\": \"tfsimple1\"\r\n",
      "          }\r\n",
      "        ],\r\n",
      "        \"output\": {\r\n",
      "          \"steps\": [\r\n",
      "            \"tfsimple1.outputs\"\r\n",
      "          ]\r\n",
      "        },\r\n",
      "        \"kubernetesMeta\": {}\r\n",
      "      },\r\n",
      "      \"state\": {\r\n",
      "        \"pipelineVersion\": 1,\r\n",
      "        \"status\": \"PipelineReady\",\r\n",
      "        \"reason\": \"created pipeline\",\r\n",
      "        \"lastChangeTimestamp\": \"2023-03-10T10:15:52.515491456Z\",\r\n",
      "        \"modelsReady\": true\r\n",
      "      }\r\n",
      "    }\r\n",
      "  ]\r\n",
      "}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline status tfsimple -w PipelineReady | jq -M ."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "86280675",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\r\n",
      "  \"model_name\": \"\",\r\n",
      "  \"outputs\": [\r\n",
      "    {\r\n",
      "      \"data\": [\r\n",
      "        2,\r\n",
      "        4,\r\n",
      "        6,\r\n",
      "        8,\r\n",
      "        10,\r\n",
      "        12,\r\n",
      "        14,\r\n",
      "        16,\r\n",
      "        18,\r\n",
      "        20,\r\n",
      "        22,\r\n",
      "        24,\r\n",
      "        26,\r\n",
      "        28,\r\n",
      "        30,\r\n",
      "        32\r\n",
      "      ],\r\n",
      "      \"name\": \"OUTPUT0\",\r\n",
      "      \"shape\": [\r\n",
      "        1,\r\n",
      "        16\r\n",
      "      ],\r\n",
      "      \"datatype\": \"INT32\"\r\n",
      "    },\r\n",
      "    {\r\n",
      "      \"data\": [\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0\r\n",
      "      ],\r\n",
      "      \"name\": \"OUTPUT1\",\r\n",
      "      \"shape\": [\r\n",
      "        1,\r\n",
      "        16\r\n",
      "      ],\r\n",
      "      \"datatype\": \"INT32\"\r\n",
      "    }\r\n",
      "  ]\r\n",
      "}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline infer tfsimple \\\n",
    "    '{\"inputs\":[{\"name\":\"INPUT0\",\"data\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],\"datatype\":\"INT32\",\"shape\":[1,16]},{\"name\":\"INPUT1\",\"data\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],\"datatype\":\"INT32\",\"shape\":[1,16]}]}' | jq -M ."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "b06ff6ab",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "apiVersion: mlops.seldon.io/v1alpha1\r\n",
      "kind: Pipeline\r\n",
      "metadata:\r\n",
      "  name: tfsimple-extended-step\r\n",
      "spec:\r\n",
      "  input:\r\n",
      "    externalInputs:\r\n",
      "      - tfsimple.step.tfsimple1.outputs\r\n",
      "    tensorMap:\r\n",
      "      tfsimple.step.tfsimple1.outputs.OUTPUT0: INPUT0\r\n",
      "      tfsimple.step.tfsimple1.outputs.OUTPUT1: INPUT1\r\n",
      "  steps:\r\n",
      "    - name: tfsimple2\r\n",
      "  output:\r\n",
      "    steps:\r\n",
      "    - tfsimple2\r\n"
     ]
    }
   ],
   "source": [
    "!cat ./pipelines/tfsimple-extended-step.yaml"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "008a1465",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline load -f ./pipelines/tfsimple-extended-step.yaml"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "7c5c2065",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\r\n",
      "  \"pipelineName\": \"tfsimple-extended-step\",\r\n",
      "  \"versions\": [\r\n",
      "    {\r\n",
      "      \"pipeline\": {\r\n",
      "        \"name\": \"tfsimple-extended-step\",\r\n",
      "        \"uid\": \"cg5g6ns6dpcs73c4qhlg\",\r\n",
      "        \"version\": 1,\r\n",
      "        \"steps\": [\r\n",
      "          {\r\n",
      "            \"name\": \"tfsimple2\"\r\n",
      "          }\r\n",
      "        ],\r\n",
      "        \"output\": {\r\n",
      "          \"steps\": [\r\n",
      "            \"tfsimple2.outputs\"\r\n",
      "          ]\r\n",
      "        },\r\n",
      "        \"kubernetesMeta\": {},\r\n",
      "        \"input\": {\r\n",
      "          \"externalInputs\": [\r\n",
      "            \"tfsimple.step.tfsimple1.outputs\"\r\n",
      "          ],\r\n",
      "          \"tensorMap\": {\r\n",
      "            \"tfsimple.step.tfsimple1.outputs.OUTPUT0\": \"INPUT0\",\r\n",
      "            \"tfsimple.step.tfsimple1.outputs.OUTPUT1\": \"INPUT1\"\r\n",
      "          }\r\n",
      "        }\r\n",
      "      },\r\n",
      "      \"state\": {\r\n",
      "        \"pipelineVersion\": 1,\r\n",
      "        \"status\": \"PipelineReady\",\r\n",
      "        \"reason\": \"created pipeline\",\r\n",
      "        \"lastChangeTimestamp\": \"2023-03-10T10:15:59.634720740Z\",\r\n",
      "        \"modelsReady\": true\r\n",
      "      }\r\n",
      "    }\r\n",
      "  ]\r\n",
      "}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline status tfsimple-extended-step -w PipelineReady | jq -M ."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "0706c855",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\r\n",
      "\t\"model_name\": \"\",\r\n",
      "\t\"outputs\": [\r\n",
      "\t\t{\r\n",
      "\t\t\t\"data\": [\r\n",
      "\t\t\t\t2,\r\n",
      "\t\t\t\t4,\r\n",
      "\t\t\t\t6,\r\n",
      "\t\t\t\t8,\r\n",
      "\t\t\t\t10,\r\n",
      "\t\t\t\t12,\r\n",
      "\t\t\t\t14,\r\n",
      "\t\t\t\t16,\r\n",
      "\t\t\t\t18,\r\n",
      "\t\t\t\t20,\r\n",
      "\t\t\t\t22,\r\n",
      "\t\t\t\t24,\r\n",
      "\t\t\t\t26,\r\n",
      "\t\t\t\t28,\r\n",
      "\t\t\t\t30,\r\n",
      "\t\t\t\t32\r\n",
      "\t\t\t],\r\n",
      "\t\t\t\"name\": \"OUTPUT0\",\r\n",
      "\t\t\t\"shape\": [\r\n",
      "\t\t\t\t1,\r\n",
      "\t\t\t\t16\r\n",
      "\t\t\t],\r\n",
      "\t\t\t\"datatype\": \"INT32\"\r\n",
      "\t\t},\r\n",
      "\t\t{\r\n",
      "\t\t\t\"data\": [\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0\r\n",
      "\t\t\t],\r\n",
      "\t\t\t\"name\": \"OUTPUT1\",\r\n",
      "\t\t\t\"shape\": [\r\n",
      "\t\t\t\t1,\r\n",
      "\t\t\t\t16\r\n",
      "\t\t\t],\r\n",
      "\t\t\t\"datatype\": \"INT32\"\r\n",
      "\t\t}\r\n",
      "\t]\r\n",
      "}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline infer tfsimple \\\n",
    "    '{\"inputs\":[{\"name\":\"INPUT0\",\"data\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],\"datatype\":\"INT32\",\"shape\":[1,16]},{\"name\":\"INPUT1\",\"data\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],\"datatype\":\"INT32\",\"shape\":[1,16]}]}' "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "7d03514f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "seldon.default.model.tfsimple1.inputs\tcg5g6ogfh5ss73a44vvg\t{\"inputs\":[{\"name\":\"INPUT0\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]}},{\"name\":\"INPUT1\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]}}]}\t\tpipeline=[tfsimple]\ttraceparent=[00-2c66ff815d920ad238365be52a4467f5-90824e4cb70c3242-01]\tx-forwarded-proto=[http]\tx-envoy-expected-rq-timeout-ms=[60000]\tx-request-id=[cg5g6ogfh5ss73a44vvg]\r\n",
      "seldon.default.model.tfsimple1.outputs\tcg5g6ogfh5ss73a44vvg\t{\"modelName\":\"tfsimple1_1\",\"modelVersion\":\"1\",\"outputs\":[{\"name\":\"OUTPUT0\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32]}},{\"name\":\"OUTPUT1\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}}]}\t\tx-request-id=[cg5g6ogfh5ss73a44vvg]\tpipeline=[tfsimple]\tx-envoy-upstream-service-time=[8]\tx-seldon-route=[:tfsimple1_1:]\ttraceparent=[00-2c66ff815d920ad238365be52a4467f5-ca023a540fa463b3-01]\tx-forwarded-proto=[http]\tx-envoy-expected-rq-timeout-ms=[60000]\r\n",
      "seldon.default.pipeline.tfsimple.inputs\tcg5g6ogfh5ss73a44vvg\t{\"inputs\":[{\"name\":\"INPUT0\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]}},{\"name\":\"INPUT1\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]}}]}\t\tpipeline=[tfsimple]\tx-request-id=[cg5g6ogfh5ss73a44vvg]\ttraceparent=[00-2c66ff815d920ad238365be52a4467f5-843d6ce39292396d-01]\tx-forwarded-proto=[http]\tx-envoy-expected-rq-timeout-ms=[60000]\r\n",
      "seldon.default.pipeline.tfsimple.outputs\tcg5g6ogfh5ss73a44vvg\t{\"outputs\":[{\"name\":\"OUTPUT0\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32]}},{\"name\":\"OUTPUT1\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}}]}\t\tx-envoy-expected-rq-timeout-ms=[60000]\tx-request-id=[cg5g6ogfh5ss73a44vvg]\tx-envoy-upstream-service-time=[8]\tx-seldon-route=[:tfsimple1_1:]\tpipeline=[tfsimple]\ttraceparent=[00-2c66ff815d920ad238365be52a4467f5-ee7527353e9fe5a2-01]\tx-forwarded-proto=[http]\r\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline inspect tfsimple --verbose"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "36b2133e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "seldon.default.model.tfsimple2.inputs\tcg5g6ogfh5ss73a44vvg\t{\"inputs\":[{\"name\":\"INPUT0\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32]}},{\"name\":\"INPUT1\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}}],\"rawInputContents\":[\"AgAAAAQAAAAGAAAACAAAAAoAAAAMAAAADgAAABAAAAASAAAAFAAAABYAAAAYAAAAGgAAABwAAAAeAAAAIAAAAA==\",\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==\"]}\r\n",
      "seldon.default.model.tfsimple2.outputs\tcg5g6ogfh5ss73a44vvg\t{\"modelName\":\"tfsimple2_1\",\"modelVersion\":\"1\",\"outputs\":[{\"name\":\"OUTPUT0\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32]}},{\"name\":\"OUTPUT1\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32]}}]}\r\n",
      "seldon.default.pipeline.tfsimple-extended-step.inputs\tcg5g6ogfh5ss73a44vvg\t{\"inputs\":[{\"name\":\"INPUT0\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32]}},{\"name\":\"INPUT1\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}}],\"rawInputContents\":[\"AgAAAAQAAAAGAAAACAAAAAoAAAAMAAAADgAAABAAAAASAAAAFAAAABYAAAAYAAAAGgAAABwAAAAeAAAAIAAAAA==\",\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==\"]}\r\n",
      "seldon.default.pipeline.tfsimple-extended-step.outputs\tcg5g6ogfh5ss73a44vvg\t{\"outputs\":[{\"name\":\"OUTPUT0\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32]}},{\"name\":\"OUTPUT1\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32]}}]}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline inspect tfsimple-extended-step"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "09e5293f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{}\n",
      "{}\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline unload tfsimple-extended-step\n",
    "!seldon pipeline unload tfsimple"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "dad54862",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{}\n",
      "{}\n"
     ]
    }
   ],
   "source": [
    "!seldon model unload tfsimple1\n",
    "!seldon model unload tfsimple2"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ec3fbaeb",
   "metadata": {},
   "source": [
    "### Pipeline pulling from two other Pipeline steps from same model\n",
    "\n",
    "![pipeline-to-pipeline](img_pipeline5.jpg)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "c5ff042a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "apiVersion: mlops.seldon.io/v1alpha1\n",
      "kind: Model\n",
      "metadata:\n",
      "  name: tfsimple1\n",
      "spec:\n",
      "  storageUri: \"gs://seldon-models/triton/simple\"\n",
      "  requirements:\n",
      "  - tensorflow\n",
      "  memory: 100Ki\n",
      "apiVersion: mlops.seldon.io/v1alpha1\n",
      "kind: Model\n",
      "metadata:\n",
      "  name: tfsimple2\n",
      "spec:\n",
      "  storageUri: \"gs://seldon-models/triton/simple\"\n",
      "  requirements:\n",
      "  - tensorflow\n",
      "  memory: 100Ki\n"
     ]
    }
   ],
   "source": [
    "!cat ./models/tfsimple1.yaml\n",
    "!cat ./models/tfsimple2.yaml"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "1218d50c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{}\n",
      "{}\n"
     ]
    }
   ],
   "source": [
    "!seldon model load -f ./models/tfsimple1.yaml \n",
    "!seldon model load -f ./models/tfsimple2.yaml "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "c853259a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{}\n",
      "{}\n"
     ]
    }
   ],
   "source": [
    "!seldon model status tfsimple1 -w ModelAvailable | jq -M .\n",
    "!seldon model status tfsimple2 -w ModelAvailable | jq -M ."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "e141244a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "apiVersion: mlops.seldon.io/v1alpha1\r\n",
      "kind: Pipeline\r\n",
      "metadata:\r\n",
      "  name: tfsimple\r\n",
      "spec:\r\n",
      "  steps:\r\n",
      "    - name: tfsimple1\r\n",
      "  output:\r\n",
      "    steps:\r\n",
      "    - tfsimple1\r\n"
     ]
    }
   ],
   "source": [
    "!cat ./pipelines/tfsimple.yaml"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "2d4e1f37",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline load -f ./pipelines/tfsimple.yaml"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "6adb818a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\r\n",
      "  \"pipelineName\": \"tfsimple\",\r\n",
      "  \"versions\": [\r\n",
      "    {\r\n",
      "      \"pipeline\": {\r\n",
      "        \"name\": \"tfsimple\",\r\n",
      "        \"uid\": \"cg5g6u46dpcs73c4qhm0\",\r\n",
      "        \"version\": 1,\r\n",
      "        \"steps\": [\r\n",
      "          {\r\n",
      "            \"name\": \"tfsimple1\"\r\n",
      "          }\r\n",
      "        ],\r\n",
      "        \"output\": {\r\n",
      "          \"steps\": [\r\n",
      "            \"tfsimple1.outputs\"\r\n",
      "          ]\r\n",
      "        },\r\n",
      "        \"kubernetesMeta\": {}\r\n",
      "      },\r\n",
      "      \"state\": {\r\n",
      "        \"pipelineVersion\": 1,\r\n",
      "        \"status\": \"PipelineReady\",\r\n",
      "        \"reason\": \"created pipeline\",\r\n",
      "        \"lastChangeTimestamp\": \"2023-03-10T10:16:24.433333171Z\",\r\n",
      "        \"modelsReady\": true\r\n",
      "      }\r\n",
      "    }\r\n",
      "  ]\r\n",
      "}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline status tfsimple -w PipelineReady | jq -M ."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "d922d330",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\r\n",
      "  \"model_name\": \"\",\r\n",
      "  \"outputs\": [\r\n",
      "    {\r\n",
      "      \"data\": [\r\n",
      "        2,\r\n",
      "        4,\r\n",
      "        6,\r\n",
      "        8,\r\n",
      "        10,\r\n",
      "        12,\r\n",
      "        14,\r\n",
      "        16,\r\n",
      "        18,\r\n",
      "        20,\r\n",
      "        22,\r\n",
      "        24,\r\n",
      "        26,\r\n",
      "        28,\r\n",
      "        30,\r\n",
      "        32\r\n",
      "      ],\r\n",
      "      \"name\": \"OUTPUT0\",\r\n",
      "      \"shape\": [\r\n",
      "        1,\r\n",
      "        16\r\n",
      "      ],\r\n",
      "      \"datatype\": \"INT32\"\r\n",
      "    },\r\n",
      "    {\r\n",
      "      \"data\": [\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0,\r\n",
      "        0\r\n",
      "      ],\r\n",
      "      \"name\": \"OUTPUT1\",\r\n",
      "      \"shape\": [\r\n",
      "        1,\r\n",
      "        16\r\n",
      "      ],\r\n",
      "      \"datatype\": \"INT32\"\r\n",
      "    }\r\n",
      "  ]\r\n",
      "}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline infer tfsimple \\\n",
    "    '{\"inputs\":[{\"name\":\"INPUT0\",\"data\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],\"datatype\":\"INT32\",\"shape\":[1,16]},{\"name\":\"INPUT1\",\"data\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],\"datatype\":\"INT32\",\"shape\":[1,16]}]}' | jq -M ."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "00f60705",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "apiVersion: mlops.seldon.io/v1alpha1\n",
      "kind: Pipeline\n",
      "metadata:\n",
      "  name: tfsimple-extended\n",
      "spec:\n",
      "  input:\n",
      "    externalInputs:\n",
      "      - tfsimple.outputs\n",
      "    tensorMap:\n",
      "      tfsimple.outputs.OUTPUT0: INPUT0\n",
      "      tfsimple.outputs.OUTPUT1: INPUT1\n",
      "  steps:\n",
      "    - name: tfsimple2\n",
      "  output:\n",
      "    steps:\n",
      "    - tfsimple2\n",
      "---\n",
      "apiVersion: mlops.seldon.io/v1alpha1\n",
      "kind: Pipeline\n",
      "metadata:\n",
      "  name: tfsimple-extended2\n",
      "spec:\n",
      "  input:\n",
      "    externalInputs:\n",
      "      - tfsimple.outputs\n",
      "    tensorMap:\n",
      "      tfsimple.outputs.OUTPUT0: INPUT0\n",
      "      tfsimple.outputs.OUTPUT1: INPUT1\n",
      "  steps:\n",
      "    - name: tfsimple2\n",
      "  output:\n",
      "    steps:\n",
      "    - tfsimple2\n",
      "---\n",
      "apiVersion: mlops.seldon.io/v1alpha1\n",
      "kind: Pipeline\n",
      "metadata:\n",
      "  name: tfsimple-combined-step\n",
      "spec:\n",
      "  input:\n",
      "    externalInputs:\n",
      "      - tfsimple-extended.step.tfsimple2.outputs.OUTPUT0\n",
      "      - tfsimple-extended2.step.tfsimple2.outputs.OUTPUT0\n",
      "    tensorMap:\n",
      "      tfsimple-extended.step.tfsimple2.outputs.OUTPUT0: INPUT0\n",
      "      tfsimple-extended2.step.tfsimple2.outputs.OUTPUT0: INPUT1\n",
      "  steps:\n",
      "    - name: tfsimple2\n",
      "  output:\n",
      "    steps:\n",
      "    - tfsimple2\n"
     ]
    }
   ],
   "source": [
    "!cat ./pipelines/tfsimple-extended.yaml\n",
    "!echo \"---\"\n",
    "!cat ./pipelines/tfsimple-extended2.yaml\n",
    "!echo \"---\"\n",
    "!cat ./pipelines/tfsimple-combined-step.yaml"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "ff620079",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{}\n",
      "{}\n",
      "{}\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline load -f ./pipelines/tfsimple-extended.yaml\n",
    "!seldon pipeline load -f ./pipelines/tfsimple-extended2.yaml\n",
    "!seldon pipeline load -f ./pipelines/tfsimple-combined-step.yaml"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "id": "a9a381a1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\"pipelineName\":\"tfsimple-extended\",\"versions\":[{\"pipeline\":{\"name\":\"tfsimple-extended\",\"uid\":\"cg5g7046dpcs73c4qhmg\",\"version\":1,\"steps\":[{\"name\":\"tfsimple2\"}],\"output\":{\"steps\":[\"tfsimple2.outputs\"]},\"kubernetesMeta\":{},\"input\":{\"externalInputs\":[\"tfsimple.outputs\"],\"tensorMap\":{\"tfsimple.outputs.OUTPUT0\":\"INPUT0\",\"tfsimple.outputs.OUTPUT1\":\"INPUT1\"}}},\"state\":{\"pipelineVersion\":1,\"status\":\"PipelineReady\",\"reason\":\"created pipeline\",\"lastChangeTimestamp\":\"2023-03-10T10:16:32.576588675Z\",\"modelsReady\":true}}]}\n",
      "{\"pipelineName\":\"tfsimple-extended2\",\"versions\":[{\"pipeline\":{\"name\":\"tfsimple-extended2\",\"uid\":\"cg5g7046dpcs73c4qhn0\",\"version\":1,\"steps\":[{\"name\":\"tfsimple2\"}],\"output\":{\"steps\":[\"tfsimple2.outputs\"]},\"kubernetesMeta\":{},\"input\":{\"externalInputs\":[\"tfsimple.outputs\"],\"tensorMap\":{\"tfsimple.outputs.OUTPUT0\":\"INPUT0\",\"tfsimple.outputs.OUTPUT1\":\"INPUT1\"}}},\"state\":{\"pipelineVersion\":1,\"status\":\"PipelineReady\",\"reason\":\"created pipeline\",\"lastChangeTimestamp\":\"2023-03-10T10:16:32.711813099Z\",\"modelsReady\":true}}]}\n",
      "{\"pipelineName\":\"tfsimple-combined-step\",\"versions\":[{\"pipeline\":{\"name\":\"tfsimple-combined-step\",\"uid\":\"cg5g7046dpcs73c4qhng\",\"version\":1,\"steps\":[{\"name\":\"tfsimple2\"}],\"output\":{\"steps\":[\"tfsimple2.outputs\"]},\"kubernetesMeta\":{},\"input\":{\"externalInputs\":[\"tfsimple-extended.step.tfsimple2.outputs.OUTPUT0\",\"tfsimple-extended2.step.tfsimple2.outputs.OUTPUT0\"],\"tensorMap\":{\"tfsimple-extended.step.tfsimple2.outputs.OUTPUT0\":\"INPUT0\",\"tfsimple-extended2.step.tfsimple2.outputs.OUTPUT0\":\"INPUT1\"}}},\"state\":{\"pipelineVersion\":1,\"status\":\"PipelineReady\",\"reason\":\"created pipeline\",\"lastChangeTimestamp\":\"2023-03-10T10:16:33.017843490Z\",\"modelsReady\":true}}]}\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline status tfsimple-extended -w PipelineReady\n",
    "!seldon pipeline status tfsimple-extended2 -w PipelineReady\n",
    "!seldon pipeline status tfsimple-combined-step -w PipelineReady"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "id": "b65a28de",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\r\n",
      "\t\"model_name\": \"\",\r\n",
      "\t\"outputs\": [\r\n",
      "\t\t{\r\n",
      "\t\t\t\"data\": [\r\n",
      "\t\t\t\t2,\r\n",
      "\t\t\t\t4,\r\n",
      "\t\t\t\t6,\r\n",
      "\t\t\t\t8,\r\n",
      "\t\t\t\t10,\r\n",
      "\t\t\t\t12,\r\n",
      "\t\t\t\t14,\r\n",
      "\t\t\t\t16,\r\n",
      "\t\t\t\t18,\r\n",
      "\t\t\t\t20,\r\n",
      "\t\t\t\t22,\r\n",
      "\t\t\t\t24,\r\n",
      "\t\t\t\t26,\r\n",
      "\t\t\t\t28,\r\n",
      "\t\t\t\t30,\r\n",
      "\t\t\t\t32\r\n",
      "\t\t\t],\r\n",
      "\t\t\t\"name\": \"OUTPUT0\",\r\n",
      "\t\t\t\"shape\": [\r\n",
      "\t\t\t\t1,\r\n",
      "\t\t\t\t16\r\n",
      "\t\t\t],\r\n",
      "\t\t\t\"datatype\": \"INT32\"\r\n",
      "\t\t},\r\n",
      "\t\t{\r\n",
      "\t\t\t\"data\": [\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0,\r\n",
      "\t\t\t\t0\r\n",
      "\t\t\t],\r\n",
      "\t\t\t\"name\": \"OUTPUT1\",\r\n",
      "\t\t\t\"shape\": [\r\n",
      "\t\t\t\t1,\r\n",
      "\t\t\t\t16\r\n",
      "\t\t\t],\r\n",
      "\t\t\t\"datatype\": \"INT32\"\r\n",
      "\t\t}\r\n",
      "\t]\r\n",
      "}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline infer tfsimple \\\n",
    "    '{\"inputs\":[{\"name\":\"INPUT0\",\"data\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],\"datatype\":\"INT32\",\"shape\":[1,16]},{\"name\":\"INPUT1\",\"data\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],\"datatype\":\"INT32\",\"shape\":[1,16]}]}' "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "id": "bc1ad2dd",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "seldon.default.model.tfsimple1.inputs\tcg5g710fh5ss73a4500g\t{\"inputs\":[{\"name\":\"INPUT0\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]}},{\"name\":\"INPUT1\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]}}]}\r\n",
      "seldon.default.model.tfsimple1.outputs\tcg5g710fh5ss73a4500g\t{\"modelName\":\"tfsimple1_1\",\"modelVersion\":\"1\",\"outputs\":[{\"name\":\"OUTPUT0\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32]}},{\"name\":\"OUTPUT1\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}}]}\r\n",
      "seldon.default.pipeline.tfsimple.inputs\tcg5g710fh5ss73a4500g\t{\"inputs\":[{\"name\":\"INPUT0\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]}},{\"name\":\"INPUT1\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]}}]}\r\n",
      "seldon.default.pipeline.tfsimple.outputs\tcg5g710fh5ss73a4500g\t{\"outputs\":[{\"name\":\"OUTPUT0\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32]}},{\"name\":\"OUTPUT1\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}}]}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline inspect tfsimple"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "id": "2eb548ac",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "seldon.default.model.tfsimple2.inputs\tcg5g710fh5ss73a4500g\t{\"inputs\":[{\"name\":\"INPUT0\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32]}},{\"name\":\"INPUT1\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32]}}],\"rawInputContents\":[\"AgAAAAQAAAAGAAAACAAAAAoAAAAMAAAADgAAABAAAAASAAAAFAAAABYAAAAYAAAAGgAAABwAAAAeAAAAIAAAAA==\",\"AgAAAAQAAAAGAAAACAAAAAoAAAAMAAAADgAAABAAAAASAAAAFAAAABYAAAAYAAAAGgAAABwAAAAeAAAAIAAAAA==\"]}\r\n",
      "seldon.default.model.tfsimple2.outputs\tcg5g710fh5ss73a4500g\t{\"modelName\":\"tfsimple2_1\",\"modelVersion\":\"1\",\"outputs\":[{\"name\":\"OUTPUT0\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64]}},{\"name\":\"OUTPUT1\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}}]}\r\n",
      "seldon.default.pipeline.tfsimple-extended.inputs\tcg5g710fh5ss73a4500g\t{\"inputs\":[{\"name\":\"INPUT0\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32]}},{\"name\":\"INPUT1\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}}],\"rawInputContents\":[\"AgAAAAQAAAAGAAAACAAAAAoAAAAMAAAADgAAABAAAAASAAAAFAAAABYAAAAYAAAAGgAAABwAAAAeAAAAIAAAAA==\",\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==\"]}\r\n",
      "seldon.default.pipeline.tfsimple-extended.outputs\tcg5g710fh5ss73a4500g\t{\"outputs\":[{\"name\":\"OUTPUT0\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32]}},{\"name\":\"OUTPUT1\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32]}}]}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline inspect tfsimple-extended"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "id": "108e2c24",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "seldon.default.model.tfsimple2.inputs\tcg5g710fh5ss73a4500g\t{\"inputs\":[{\"name\":\"INPUT0\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32]}},{\"name\":\"INPUT1\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32]}}],\"rawInputContents\":[\"AgAAAAQAAAAGAAAACAAAAAoAAAAMAAAADgAAABAAAAASAAAAFAAAABYAAAAYAAAAGgAAABwAAAAeAAAAIAAAAA==\",\"AgAAAAQAAAAGAAAACAAAAAoAAAAMAAAADgAAABAAAAASAAAAFAAAABYAAAAYAAAAGgAAABwAAAAeAAAAIAAAAA==\"]}\r\n",
      "seldon.default.model.tfsimple2.outputs\tcg5g710fh5ss73a4500g\t{\"modelName\":\"tfsimple2_1\",\"modelVersion\":\"1\",\"outputs\":[{\"name\":\"OUTPUT0\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64]}},{\"name\":\"OUTPUT1\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}}]}\r\n",
      "seldon.default.pipeline.tfsimple-extended2.inputs\tcg5g710fh5ss73a4500g\t{\"inputs\":[{\"name\":\"INPUT0\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32]}},{\"name\":\"INPUT1\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}}],\"rawInputContents\":[\"AgAAAAQAAAAGAAAACAAAAAoAAAAMAAAADgAAABAAAAASAAAAFAAAABYAAAAYAAAAGgAAABwAAAAeAAAAIAAAAA==\",\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==\"]}\r\n",
      "seldon.default.pipeline.tfsimple-extended2.outputs\tcg5g710fh5ss73a4500g\t{\"outputs\":[{\"name\":\"OUTPUT0\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32]}},{\"name\":\"OUTPUT1\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32]}}]}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline inspect tfsimple-extended2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "id": "239a6b9d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "seldon.default.model.tfsimple2.inputs\tcg5g710fh5ss73a4500g\t{\"inputs\":[{\"name\":\"INPUT0\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32]}},{\"name\":\"INPUT1\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32]}}],\"rawInputContents\":[\"AgAAAAQAAAAGAAAACAAAAAoAAAAMAAAADgAAABAAAAASAAAAFAAAABYAAAAYAAAAGgAAABwAAAAeAAAAIAAAAA==\",\"AgAAAAQAAAAGAAAACAAAAAoAAAAMAAAADgAAABAAAAASAAAAFAAAABYAAAAYAAAAGgAAABwAAAAeAAAAIAAAAA==\"]}\r\n",
      "seldon.default.model.tfsimple2.outputs\tcg5g710fh5ss73a4500g\t{\"modelName\":\"tfsimple2_1\",\"modelVersion\":\"1\",\"outputs\":[{\"name\":\"OUTPUT0\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64]}},{\"name\":\"OUTPUT1\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}}]}\r\n",
      "seldon.default.pipeline.tfsimple-combined-step.inputs\tcg5g710fh5ss73a4500g\t{\"inputs\":[{\"name\":\"INPUT0\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32]}},{\"name\":\"INPUT1\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32]}}],\"rawInputContents\":[\"AgAAAAQAAAAGAAAACAAAAAoAAAAMAAAADgAAABAAAAASAAAAFAAAABYAAAAYAAAAGgAAABwAAAAeAAAAIAAAAA==\",\"AgAAAAQAAAAGAAAACAAAAAoAAAAMAAAADgAAABAAAAASAAAAFAAAABYAAAAYAAAAGgAAABwAAAAeAAAAIAAAAA==\"]}\r\n",
      "seldon.default.pipeline.tfsimple-combined-step.outputs\tcg5g710fh5ss73a4500g\t{\"outputs\":[{\"name\":\"OUTPUT0\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64]}},{\"name\":\"OUTPUT1\",\"datatype\":\"INT32\",\"shape\":[\"1\",\"16\"],\"contents\":{\"intContents\":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}}]}\r\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline inspect tfsimple-combined-step"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "id": "840af9e6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{}\n",
      "{}\n",
      "{}\n",
      "{}\n"
     ]
    }
   ],
   "source": [
    "!seldon pipeline unload tfsimple-extended\n",
    "!seldon pipeline unload tfsimple-extended2\n",
    "!seldon pipeline unload tfsimple-combined-step\n",
    "!seldon pipeline unload tfsimple"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "id": "3f2584b3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{}\n",
      "{}\n"
     ]
    }
   ],
   "source": [
    "!seldon model unload tfsimple1\n",
    "!seldon model unload tfsimple2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "503c0778",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
